package stringdemo;

import stringdemo.Exception.PassWordException;
import stringdemo.Exception.UserNameException;

import java.util.Scanner;

public class Test {

    public static void login(User user) {
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入用户名：");
        String userName = sc.nextLine();
        System.out.println("请输入密码：");
        String passWord = sc.nextLine();


        if(! user.getUserName().equals(userName)) {
            throw new UserNameException("用户名错误，您输入的用户名是：" + userName);
        }

        if(! user.getPassWord().equals(passWord)) {
            throw new PassWordException("密码错误，您输入的密码是："+passWord);
        }

        System.out.println("登陆成功！");
    }

    public static void main(String[] args) {
        User user = new User("djm","1234567");
        login(user);
    }
}
